package com.ag.wzp.dao;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.ag.bean.TbDisposalAdvice;
import com.ag.bean.TbEventmackup;
import com.ag.bean.TbMackupAnnex;
import com.ag.dao.TbEventmackupDAO;
import com.ag.dao.TbMackupAnnexDAO;

import common.Logger;

@Repository("wzpTbMackupAnnexDAO")
public class WzpTbMackupAnnexDAO extends TbMackupAnnexDAO {
	private static final Logger logger = Logger.getLogger(WzpTbMackupAnnexDAO.class);
	
	private SessionFactory sessionFacotry;   
    @Resource  
    public void setSessionFacotry(SessionFactory sessionFacotry) {   
        this.sessionFacotry = sessionFacotry;   
    }   
    @PostConstruct  
    public void injectSessionFactory() {   
        super.setSessionFactory(sessionFacotry);
    }
    
	public List<TbMackupAnnex> findAnnexByEId(String eId) {
		logger.debug("findAnnexByEId");
		try {
			String hql = "from TbMackupAnnex annex join fetch annex.tbEventmackup mackup join fetch mackup.tbEvent e " +
					" where e.EId = '"+eId +"' and annex.a = '0'";
			return getHibernateTemplate().find(hql);
		} catch (RuntimeException re) {
			logger.error("findAnnexByEId failed", re);
			throw re;
		}
	} 
}
